package com.open.capacity.user.controller;

import com.open.capacity.annotation.log.LogAnnotation;
import com.open.capacity.commons.Result;
import com.open.capacity.user.model.Sys3auth;
import com.open.capacity.user.model.SysCompany;
import com.open.capacity.user.service.Sys3authService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;

/**
 * @author 作者 ftquan E-mail: 464725602@qq.com
 * @version 创建时间：2017年11月12日 上午22:57:51
 * 公司管理
 */
@RestController
@Api(tags = "三权模块api")
public class Sys3authController {

    private static Logger logger = LoggerFactory.getLogger(Sys3authController.class);


    @Autowired
    private Sys3authService authService;


    /**
     * 查询配置
     *
     * @param params
     * @return
     */
    @GetMapping("/auth3s")
    public Result<Sys3auth> findCompanys(@RequestParam Map<String, Object> params) {
        Sys3auth list = authService.find();
        return Result.succeed(list);

    }

    /**
     * 配置三权
     *
     * @return
     */
    @ApiOperation(value = "配置三权")
    @PostMapping("/auth3s/setAdmins")
    @LogAnnotation(module = "机构", name = "配置三权")
    public Result setAdmins(@RequestBody Sys3auth auth)  {
        try {
            authService.setAdmins(auth);
            return Result.succeed("操作成功");
        } catch (Exception e) {
            return Result.failed(e.getMessage());
        }
    }

}
